; ORIGINAL: 3dt2.1/examples/filter.scm
; $Id: filter.scm,v 1.5 1997/05/01 15:48:10 jread Exp $
;- filter.scm -----------------------------------------------------
; Demonstrate entity filtering by color and entity type.
;------------------------------------------------------------------
;; Create some entities to illustrate the use of filters
(part:clear)
(env:set-default-color 1)
(solid:block (position 0 0 0) (position 20 30 40))
(edge:linear (position 0 0 0) (position 10 10 10))
(edge:circular (position 0 0 0) 20)
(env:set-default-color 2)
(solid:sphere (position 20 30 40) 30)
(solid:cylinder (position 40 40 0) (position 40 40 40) 10)
(edge:linear (position 0 50 0) (position 50 50 0))
(edge:spline (list (position 20 20 20) (position 10 20 30) (position 50 40 10)))

;; List entities in part which match various filters
(display (filter:apply (filter:color 1) (part:entities)))
(newline)
(display (filter:apply (filter:type "solid?") (part:entities)))
(newline)

;; Pick entities according to different filters
(format #t "~a" "Pick a green entity: ")
(display (pick:entity (read-event) (filter:color 2)))
(newline)

(format #t "~a" "Pick a solid entity: ")
(display (pick:entity (read-event) (filter:type "solid?")))
(newline)

(format #t "~a" "Pick a green solid: ")
(display (pick:entity (read-event) (filter:and (filter:color 2) (filter:type "solid?"))))
(newline)

(format #t "~a" "Pick a line or arc: ")
(display (pick:entity (read-event) (filter:or (filter:type "edge:linear?") (filter:type "edge:circular?"))))
(newline)

(format #t "~a" "Pick anything except a line: ")
(display (pick:entity (read-event) (filter:not (filter:type "edge:linear?"))))
(newline)
